From e683c0e1fcc67b5219863e50ff5acc56e90f3ba9 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Fri, 29 Jan 2021 19:59:30 -0700 Subject: [PATCH] found the bug --- unoptimized_lr/simple_lr_stack.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/unoptimized_lr/simple_lr_stack.py b/unoptimized_lr/simple_lr_stack.py index 9b1eab5..a8e5bff 100644 --- a/unoptimized_lr/simple_lr_stack.py +++ b/unoptimized_lr/simple_lr_stack.py @@ -44,7 +44,6 @@ class ParseStack(Elaboratable): self.depth = depth # Control inputs - self.command_port = Signal(3) # The commands are as follows: # 0: push # 1: pop @@ -72,6 +71,7 @@ class ParseStack(Elaboratable): m.submodules.rport = rport = (self.mem).read_port() m.submodules.wport = wport = (self.mem).write_port() stack_pointer = Signal(range(self.depth), reset=0) + popsigg = Signal(1) # To represent the state of a k-item stack, we need an additional bit of state to @@ -124,23 +124,27 @@ class ParseStack(Elaboratable): with m.State("AT_LEAST_ONE_ITEM"): with m.If(self.bus.valid_in == 1): - with m.Switch(self.command_port): + with m.Switch(self.bus.command_in): with m.Case(self.PUSH): m.d.sync += stack_pointer.eq(stack_pointer + 1) m.d.comb += wport.addr.eq(stack_pointer + 1) m.d.comb += wport.data.eq(self.bus.data_in) m.d.comb += wport.en.eq(1) + m.d.comb += popsigg.eq(0) + m.next = "AT_LEAST_ONE_ITEM" + with m.Case(self.POP): + m.d.comb += popsigg.eq(1) m.d.comb += rport.addr.eq(stack_pointer) m.d.comb += self.bus.data_out.eq(rport.data) m.d.comb += self.bus.valid_out.eq(1) - with m.If(stack_pointer == 0): m.next = "EMPTY" with m.Else(): m.next = "AT_LEAST_ONE_ITEM" m.d.sync += stack_pointer.eq(stack_pointer - 1) + with m.Case(self.MULTIPOP): with m.If((self.bus.index_in - 1 ) > stack_pointer): m.d.comb += self.bus.internal_fault.eq(1) @@ -210,8 +214,10 @@ class DummyPlug(Elaboratable): m.d.comb += m.submodules.stack.bus.data_in.eq(44) with m.If(counter==4): - m.d.comb += m.submodules.stack.bus.command_in.eq(ParseStack.POP) + m.d.comb += m.submodules.stack.bus.command_in.eq(ParseStack.PUSH) m.d.comb += m.submodules.stack.bus.valid_in.eq(1) + m.d.comb += m.submodules.stack.bus.data_in.eq(69) + with m.If(counter==5): m.d.comb += m.submodules.stack.bus.command_in.eq(ParseStack.POP) -- GitLab