Method: CPU#controller
- Defined in:
-
lib/HDLRuby/hdr_samples/sw_encrypt_cpu_bench.rb,
lib/HDLRuby/hdr_samples/sw_encrypt_cpusim_bench.rb
Generates the bus controller.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/HDLRuby/hdr_samples/sw_encrypt_cpu_bench.rb', line 65 def controller clk,rst,req,ack = @clk,@rst,@req,@ack abus,dbus,rwb = @abus,@dbus,@rwb allocator = @allocator HDLRuby::High.cur_system.open do par(clk) do # Bus controller hcase(abus) hif(req) do ack <= 1 allocator.each do |sig,addr| hwhen(addr) do hif(rwb) { dbus <= sig } helse { sig <= dbus } end end end helse do ack <= 0 end end end ## Generates a read of sig executing +ruby_block+ on the result. def read(sig,&ruby_block) addr = @allocator.get(sig) hif(ack == 0) do @abus <= addr @rwb <= 1 @req <= 1 helse @req <= 0 ruby_block.call(@dbus) end end ## Generates a write +val+ to +sig+ executing +ruby_block+ # in case of success. def write(val,sig,&ruby_block) addr = @allocator.get(sig) hif(ack == 0) do @abus <= addr @dbus <= val @rwb <= 0 @req <= 1 helse @req <= 0 ruby_block.call end end end |