X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fadd%2Fexample_buf_pipe.py;h=b83d5035cc01c7ec338c1589359323b213e3099f;hb=f3945d1317aa236b752c1e286801caa2c3a07703;hp=15d368c291d5a737c1b73c5a53bfa82c00ce09bb;hpb=f201e4d673a3d15db93de5a6b79eceab6b89ba0d;p=ieee754fpu.git diff --git a/src/add/example_buf_pipe.py b/src/add/example_buf_pipe.py index 15d368c2..b83d5035 100644 --- a/src/add/example_buf_pipe.py +++ b/src/add/example_buf_pipe.py @@ -45,19 +45,23 @@ from nmigen import Signal, Cat, Const, Mux, Module from nmigen.cli import verilog, rtlil +from nmigen.hdl.rec import Record, Layout + from collections.abc import Sequence class PrevControl: """ contains signals that come *from* the previous stage (both in and out) - * i_valid: input from previous stage indicating incoming data is valid + * i_valid: previous stage indicating all incoming data is valid. + may be a multi-bit signal, where all bits are required + to be asserted to indicate "valid". * o_ready: output to next stage indicating readiness to accept data * i_data : an input - added by the user of this class """ - def __init__(self): - self.i_valid = Signal(name="p_i_valid") # >>in - self.o_ready = Signal(name="p_o_ready") # <>in self + self.o_ready = Signal(name="p_o_ready") # prev < 1: # multi-bit case: valid only when i_valid is all 1s + all1s = Const(-1, (len(self.i_valid), False)) + return self.i_valid == all1s + # single-bit i_valid case + return self.i_valid + class NextControl: """ contains the signals that go *to* the next stage (both in and out) @@ -76,8 +88,8 @@ class NextControl: * o_data : an output - added by the user of this class """ def __init__(self): - self.o_valid = Signal(name="n_o_valid") # out>> - self.i_ready = Signal(name="n_i_ready") # <> next + self.i_ready = Signal(name="n_i_ready") # self <