Commit a47afa96 by Zachary Snow

don't force int types to be regs

parent ecaaec9c
...@@ -144,7 +144,7 @@ elaborateIntegerAtom other = other ...@@ -144,7 +144,7 @@ elaborateIntegerAtom other = other
-- size; if not unspecified, the first signing overrides the second -- size; if not unspecified, the first signing overrides the second
baseIntType :: Signing -> Signing -> Int -> Type baseIntType :: Signing -> Signing -> Int -> Type
baseIntType sgOverride sgBase size = baseIntType sgOverride sgBase size =
IntegerVector TReg sg [(RawNum hi, RawNum 0)] IntegerVector TLogic sg [(RawNum hi, RawNum 0)]
where where
hi = fromIntegral $ size - 1 hi = fromIntegral $ size - 1
sg = if sgOverride /= Unspecified sg = if sgOverride /= Unspecified
......
module Example(
input int inp,
output int out
);
assign out = inp * 2;
endmodule
module Example(
input wire signed [31:0] inp,
output wire signed [31:0] out
);
assign out = inp * 2;
endmodule
module top;
reg signed [31:0] inp;
wire signed [31:0] out;
Example e(inp, out);
initial begin
#1 inp = 1;
#1 inp = 5;
#1 inp = 10;
#1 inp = 7;
end
endmodule
...@@ -7,8 +7,12 @@ module sub(intf_i p, intf_i q [2]); ...@@ -7,8 +7,12 @@ module sub(intf_i p, intf_i q [2]);
typedef q[0].data_t q_data_t; // interface based typedef typedef q[0].data_t q_data_t; // interface based typedef
p_data_t p_data; p_data_t p_data;
q_data_t q_data; q_data_t q_data;
initial $display("p %0d %b", $bits(p_data), p_data); initial begin
initial $display("q %0d %b", $bits(q_data), q_data); p_data = 1;
q_data = 2;
$display("p %0d %b", $bits(p_data), p_data);
$display("q %0d %b", $bits(q_data), q_data);
end
endmodule endmodule
module top; module top;
......
module top; module top;
initial $display("p %0d %b", 32, 32'bx); initial $display("p %0d %b", 32, 32'd1);
initial $display("q %0d %b", 32, 32'bx); initial $display("q %0d %b", 32, 32'd2);
endmodule endmodule
...@@ -14,9 +14,12 @@ ...@@ -14,9 +14,12 @@
`define ASSERT_UNSIGNED(expr) `ASSERT_SIGNEDNESS(expr, unsigned, 0) `define ASSERT_UNSIGNED(expr) `ASSERT_SIGNEDNESS(expr, unsigned, 0)
`define MAKE_PRIM(typ) \ `define MAKE_PRIM(typ) \
typ typ``_unspecified = 1; \ typ typ``_unspecified; \
typ unsigned typ``_unsigned = 1; \ typ unsigned typ``_unsigned; \
typ signed typ``_signed = 1; \ typ signed typ``_signed; \
initial typ``_unspecified = 1; \
initial typ``_unsigned = 1; \
initial typ``_signed = 1; \
`ASSERT_SIGNED(typ``_signed) \ `ASSERT_SIGNED(typ``_signed) \
`ASSERT_UNSIGNED(typ``_unsigned) `ASSERT_UNSIGNED(typ``_unsigned)
......
`define MAKE_PRIM(typ, base, size) \ `define MAKE_PRIM(typ, size) \
base [size-1:0] typ``_unspecified = 1; \ reg [size-1:0] typ``_unspecified = 1; \
base [size-1:0] typ``_unsigned = 1; \ reg [size-1:0] typ``_unsigned = 1; \
base signed [size-1:0] typ``_signed = 1; reg signed [size-1:0] typ``_signed = 1;
module top; module top;
wire signed x; wire signed x;
...@@ -14,17 +14,17 @@ module top; ...@@ -14,17 +14,17 @@ module top;
assign w = z; assign w = z;
initial #1 $display("%b %b %b %b", x, y, z, w); initial #1 $display("%b %b %b %b", x, y, z, w);
`MAKE_PRIM(byte, reg, 8) `MAKE_PRIM(byte, 8)
`MAKE_PRIM(shortint, reg, 16) `MAKE_PRIM(shortint, 16)
`MAKE_PRIM(int, reg, 32) `MAKE_PRIM(int, 32)
integer integer_unspecified = 1; integer integer_unspecified = 1;
reg [31:0] integer_unsigned = 1; reg [31:0] integer_unsigned = 1;
integer integer_signed = 1; integer integer_signed = 1;
`MAKE_PRIM(longint, reg, 64) `MAKE_PRIM(longint, 64)
`MAKE_PRIM(bit, wire, 1) `MAKE_PRIM(bit, 1)
`MAKE_PRIM(reg, reg, 1) `MAKE_PRIM(reg, 1)
`MAKE_PRIM(logic, wire, 1) `MAKE_PRIM(logic, 1)
reg signed [5:0] arr; reg signed [5:0] arr;
endmodule endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment