Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 9v006596bb0c00000000025f

Instance creation in Verilog

Creating an instance of a module is a very frequent task in Verilog. Let's see how efficiently can it be done

Start file
module sram #(
  parameter AW = 12,
  parameter DW = 32
)(
  input clk,
  input rstn,
  input wr,
  input rd,
  input [AW-1:0] addr,
  input [DW-1:0] wdata,
  output [DW-1:0] rdata
);
  // here goes the SRAM model
  // ...
endmodule
End file
  wire        w_clk;
  wire        w_rstn;
  wire        w_wr;
  wire        w_rd;
  wire [ 7:0] w_addr;
  wire [15:0] w_wdata;
  wire [15:0] w_rdata;

  sram #(
    .AW   (8),
    .DW   (16)
  ) i0_sram (
    .clk  (w_clk),
    .rstn (w_rstn),
    .wr   (w_wr),
    .rd   (w_rd),
    .addr (w_addr),
    .wdata(w_wdata),
    .rdata(w_rdata)
  );

View Diff

1,15c1,20
< module sram #(
<   parameter AW = 12,
<   parameter DW = 32
< )(
<   input clk,
<   input rstn,
<   input wr,
<   input rd,
<   input [AW-1:0] addr,
<   input [DW-1:0] wdata,
<   output [DW-1:0] rdata
< );
<   // here goes the SRAM model
<   // ...
< endmodule
---
>   wire        w_clk;
>   wire        w_rstn;
>   wire        w_wr;
>   wire        w_rd;
>   wire [ 7:0] w_addr;
>   wire [15:0] w_wdata;
>   wire [15:0] w_rdata;
> 
>   sram #(
>     .AW   (8),
>     .DW   (16)
>   ) i0_sram (
>     .clk  (w_clk),
>     .rstn (w_rstn),
>     .wr   (w_wr),
>     .rd   (w_rd),
>     .addr (w_addr),
>     .wdata(w_wdata),
>     .rdata(w_rdata)
>   );

Solutions by @MonkieeBoi:

Unlock 3 remaining solutions by signing in and submitting your own entry
Created by: @5S-Goran

7 active golfers, 33 entries

Solutions by @MonkieeBoi:
146
#5 - MonkieeBoi / @MonkieeBoi

02/02/2024 at 10:15AM

151
#>5 - MonkieeBoi / @MonkieeBoi

02/02/2024 at 09:55AM

158
#>5 - MonkieeBoi / @MonkieeBoi

02/02/2024 at 09:40AM