Sha256: 681a78236cdd1b3c0ba5a1854a6dff65ac8d7a0f195dc6b1ffa952fd0980a47a
Contents?: true
Size: 1.3 KB
Versions: 6
Compression:
Stored size: 1.3 KB
Contents
# A simple counter system :counter do input :clk, :rst input :ctrl [8].output :q output :c [8].inner :qq inner :cc instance :add do [8].input :x,:y [9].output :z z <= x.as([9]) + y end par do hif(rst) { [cc,qq] <= 0 } helse do hif(ctrl == 1) { add.(q,-1,[cc,qq]) } helse { add.(q,1,[cc,qq]) } end end par(clk.posedge) do q <= qq c <= cc end end # A benchmark for the counter. system :counter_bench do inner :clk, :rst inner :ctrl [8].inner :q inner :c counter(:my_counter).(clk,rst,ctrl,q,c) timed do clk <= 0 rst <= 0 ctrl <= 0 !10.ns clk <= 1 rst <= 0 !10.ns clk <= 0 rst <= 1 !10.ns clk <= 1 rst <= 1 !10.ns clk <= 0 rst <= 0 !10.ns clk <= 1 rst <= 0 !10.ns 10.times do clk <= 0 rst <= 0 !10.ns clk <= 1 rst <= 0 !10.ns end ctrl <= 1 20.times do clk <= 0 rst <= 0 !10.ns clk <= 1 rst <= 0 !10.ns end end end
Version data entries
6 entries across 6 versions & 1 rubygems