File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,27 @@ def sim_test():
351351 sim .add_process (sim_test ())
352352 sim .run ()
353353
354+ def test_coarse_granularity (self ):
355+ dut = Decoder (addr_width = 3 , data_width = 32 )
356+ sub = Interface (addr_width = 2 , data_width = 32 )
357+ sub .memory_map = MemoryMap (addr_width = 2 , data_width = 32 )
358+ dut .add (sub )
359+
360+ def sim_test ():
361+ yield dut .bus .cyc .eq (1 )
362+
363+ yield dut .bus .adr .eq (0x0 )
364+ yield Delay (1e-6 )
365+ self .assertEqual ((yield sub .cyc ), 1 )
366+
367+ yield dut .bus .adr .eq (0x4 )
368+ yield Delay (1e-6 )
369+ self .assertEqual ((yield sub .cyc ), 0 )
370+
371+ with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
372+ sim .add_process (sim_test ())
373+ sim .run ()
374+
354375
355376class ArbiterTestCase (unittest .TestCase ):
356377 def setUp (self ):
Original file line number Diff line number Diff line change @@ -289,7 +289,8 @@ def elaborate(self, platform):
289289 if hasattr (sub_bus , "bte" ):
290290 m .d .comb += sub_bus .bte .eq (getattr (self .bus , "bte" , BurstTypeExt .LINEAR ))
291291
292- with m .Case (sub_pat [:- log2_int (self .bus .data_width // self .bus .granularity )]):
292+ granularity_bits = log2_int (self .bus .data_width // self .bus .granularity )
293+ with m .Case (sub_pat [:- granularity_bits if granularity_bits > 0 else None ]):
293294 m .d .comb += [
294295 sub_bus .cyc .eq (self .bus .cyc ),
295296 self .bus .dat_r .eq (sub_bus .dat_r ),
You can’t perform that action at this time.
0 commit comments