mirror of
https://github.com/zachjs/sv2v.git
synced 2026-09-03 08:33:46 +02:00
revised struct pattern representation
- pattern keys now represented as TypeOrExpr - support for simple integer struct pattern keys
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
module top;
|
||||
parameter PARAM = 1;
|
||||
|
||||
`define BASE(expr, full, x, y, z) \
|
||||
$display(`"%b %0d %0d %0d expr`", \
|
||||
full, x, y, z)
|
||||
|
||||
`ifndef TEST
|
||||
typedef byte T;
|
||||
typedef struct packed {
|
||||
byte x;
|
||||
T y;
|
||||
integer z;
|
||||
} S;
|
||||
|
||||
`define TEST(a, b, c, expr) \
|
||||
if (PARAM) begin \
|
||||
S s; \
|
||||
assign s = expr; \
|
||||
initial `BASE(expr, s, s.x, s.y, s.z); \
|
||||
end
|
||||
`endif
|
||||
|
||||
`TEST(1, 2, 3, '{ x: 1, y: 2, z: 3 })
|
||||
`TEST(2, 2, 3, '{ byte: 2, integer: 3 })
|
||||
`TEST(3, 3, 2, '{ integer: 2, byte: 3 })
|
||||
`TEST(4, 4, 2, '{ integer: 2, T: 4 })
|
||||
`TEST(5, 5, 2, '{ integer: 2, T: 4, byte: 5 })
|
||||
`TEST(5, 5, 2, '{ 2: 2, byte: 5 })
|
||||
`TEST(7, 8, 9, '{ 1: 8, 2: 9, 0: 7 })
|
||||
endmodule
|
||||
@@ -0,0 +1,10 @@
|
||||
`define TEST(aVal, bVal, cVal, expr) \
|
||||
if (PARAM) begin \
|
||||
wire [7:0] a, b; \
|
||||
wire [31:0] c; \
|
||||
assign a = aVal; \
|
||||
assign b = bVal; \
|
||||
assign c = cVal; \
|
||||
initial `BASE(expr, {a, b, c}, a, b, c); \
|
||||
end
|
||||
`include "pattern_revised.sv"
|
||||
Reference in New Issue
Block a user