Skip to content

Commit bb49b1f

Browse files
authored
Merge pull request #8 from LeeKaiXuan/main
Support bit-selects
2 parents 7201d01 + 50e2a52 commit bb49b1f

File tree

21 files changed

+420
-76
lines changed

21 files changed

+420
-76
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include ${PSS_HOME}/samples/Make.vars
2+
3+
gentarget:
4+
$(PSSGEN) test.pss -o test.s -root pss_top::root_a || true
5+
6+
clean:
7+
rm -f test.s result.log
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*!
2+
@weakgroup test
3+
@{
4+
@file
5+
@author Luther Lee
6+
@data 2023/08/15
7+
@brief Test <i>bit-select</i> primary expressions.
8+
@version
9+
Portable Test and Stimulus Standard Version 2.0 <br>
10+
> Section 9.6 : Primary expressions <br>
11+
> Section 9.6.1 : Bit-selects and part-selects <br>
12+
13+
14+
---------------------------------------------------------------------------------------------------
15+
16+
### Test Command
17+
@code{.unparsed}
18+
make gentarget
19+
@endcode
20+
*/
21+
component pss_top {
22+
action root_a {
23+
bit [8] byte_0 = 8 'b0011_0011;
24+
bit [8] byte_1 = 8 'b0110_0110;
25+
bit [8] byte_2 = 8 'b1100_1100;
26+
bit [8] byte_3 = 8 'b1001_1001;
27+
bit [8] byte_4 = 8 'b0010_0010;
28+
29+
exec post_solve {
30+
byte_0[1] = 0;
31+
byte_1[3] = 2'b10;
32+
byte_2[1] = byte_2[2];
33+
byte_3[2] |= byte_3[3];
34+
byte_4 |= byte_4[1];
35+
}
36+
37+
exec body ASM =
38+
"""
39+
byte_0 = {{byte_0}} = {{byte_0[7]}}{{byte_0[6]}}{{byte_0[5]}}{{byte_0[4]}}{{byte_0[3]}}{{byte_0[2]}}{{byte_0[1]}}{{byte_0[0]}}
40+
byte_1 = {{byte_1}} = {{byte_1[7]}}{{byte_1[6]}}{{byte_1[5]}}{{byte_1[4]}}{{byte_1[3]}}{{byte_1[2]}}{{byte_1[1]}}{{byte_1[0]}}
41+
byte_2 = {{byte_2}} = {{byte_2[7]}}{{byte_2[6]}}{{byte_2[5]}}{{byte_2[4]}}{{byte_2[3]}}{{byte_2[2]}}{{byte_2[1]}}{{byte_2[0]}}
42+
byte_3 = {{byte_3}} = {{byte_3[7]}}{{byte_3[6]}}{{byte_3[5]}}{{byte_3[4]}}{{byte_3[3]}}{{byte_3[2]}}{{byte_3[1]}}{{byte_3[0]}}
43+
byte_4 = {{byte_4}} = {{byte_4[7]}}{{byte_4[6]}}{{byte_4[5]}}{{byte_4[4]}}{{byte_4[3]}}{{byte_4[2]}}{{byte_4[1]}}{{byte_4[0]}}
44+
""";
45+
}
46+
}
47+
48+
/**@}*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
byte_0 = 49 = 00110001
3+
byte_1 = 110 = 01101110
4+
byte_2 = 206 = 11001110
5+
byte_3 = 157 = 10011101
6+
byte_4 = 35 = 00100011
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include ${PSS_HOME}/samples/Make.vars
2+
3+
gentarget:
4+
$(PSSGEN) test.pss -o test.s -root pss_top::root_a || true
5+
6+
clean:
7+
rm -f test.s result.log
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*!
2+
@weakgroup test
3+
@{
4+
@file
5+
@author Luther Lee
6+
@data 2023/08/23
7+
@brief Test <i>index operator</i> `[]` applied to array.
8+
@version
9+
Portable Test and Stimulus Standard Version 2.0 <br>
10+
> Section 8.8 : Collections <br>
11+
> Section 8.8.2 : Arrays <br>
12+
> Section 8.8.2.1 : Array operators <br>
13+
> Section 9.6 : Primary expressions <br>
14+
> Section 9.6.2 : Selecting an element from a collection (indexing) <br>
15+
16+
17+
---------------------------------------------------------------------------------------------------
18+
19+
### Test Command
20+
@code{.unparsed}
21+
make gentarget
22+
@endcode
23+
*/
24+
component pss_top {
25+
action root_a {
26+
bit [4] nibbleArray_0 [3] = {4'b1100, 4'b0110, 4'b0011};
27+
array<bit [4], 3> nibbleArray_1 = {4'b1100, 4'b0110, 4'b0011};
28+
bit [4] nibble_0_0 = 4'b0001;
29+
bit [4] nibble_0_1 = 4'b0010;
30+
bit [4] nibble_0_2 = 4'b0100;
31+
bit [4] nibble_1_0 = 4'b0001;
32+
bit [4] nibble_1_1 = 4'b0010;
33+
bit [4] nibble_1_2 = 4'b0100;
34+
35+
exec post_solve {
36+
nibbleArray_0[0] = 4'b0110;
37+
nibbleArray_0[1] = nibbleArray_0[2];
38+
nibbleArray_0[2] |= nibbleArray_0[0];
39+
40+
nibbleArray_1[0] = 4'b0110;
41+
nibbleArray_1[1] = nibbleArray_1[2];
42+
nibbleArray_1[2] |= nibbleArray_1[0];
43+
44+
nibble_0_0 = nibbleArray_0[0];
45+
nibble_0_1 = nibbleArray_0[1];
46+
nibble_0_2 = nibbleArray_0[2];
47+
48+
nibble_1_0 = nibbleArray_1[0];
49+
nibble_1_1 = nibbleArray_1[1];
50+
nibble_1_2 = nibbleArray_1[2];
51+
}
52+
53+
exec body ASM =
54+
"""
55+
nibble_0_0 = {{nibble_0_0}} = {{nibble_0_0[3]}}{{nibble_0_0[2]}}{{nibble_0_0[1]}}{{nibble_0_0[0]}}
56+
nibble_0_1 = {{nibble_0_1}} = {{nibble_0_1[3]}}{{nibble_0_1[2]}}{{nibble_0_1[1]}}{{nibble_0_1[0]}}
57+
nibble_0_2 = {{nibble_0_2}} = {{nibble_0_2[3]}}{{nibble_0_2[2]}}{{nibble_0_2[1]}}{{nibble_0_2[0]}}
58+
nibble_1_0 = {{nibble_1_0}} = {{nibble_1_0[3]}}{{nibble_1_0[2]}}{{nibble_1_0[1]}}{{nibble_1_0[0]}}
59+
nibble_1_1 = {{nibble_1_1}} = {{nibble_1_1[3]}}{{nibble_1_1[2]}}{{nibble_1_1[1]}}{{nibble_1_1[0]}}
60+
nibble_1_2 = {{nibble_1_2}} = {{nibble_1_2[3]}}{{nibble_1_2[2]}}{{nibble_1_2[1]}}{{nibble_1_2[0]}}
61+
""";
62+
}
63+
}
64+
65+
/**@}*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
nibble_0_0 = 6 = 0110
3+
nibble_0_1 = 3 = 0011
4+
nibble_0_2 = 7 = 0111
5+
nibble_1_0 = 6 = 0110
6+
nibble_1_1 = 3 = 0011
7+
nibble_1_2 = 7 = 0111
8+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include ${PSS_HOME}/samples/Make.vars
2+
3+
gentarget:
4+
$(PSSGEN) test.pss -o test.s -root pss_top::root_a || true
5+
6+
clean:
7+
rm -f test.s result.log
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*!
2+
@weakgroup test
3+
@{
4+
@file
5+
@author Luther Lee
6+
@data 2023/08/23
7+
@brief Test <i>index operator</i> `[]` applied to list.
8+
@version
9+
Portable Test and Stimulus Standard Version 2.0 <br>
10+
> Section 8.8 : Collections <br>
11+
> Section 8.8.3 : Lists <br>
12+
> Section 8.8.3.1 : List operators <br>
13+
> Section 9.6 : Primary expressions <br>
14+
> Section 9.6.2 : Selecting an element from a collection (indexing) <br>
15+
16+
17+
---------------------------------------------------------------------------------------------------
18+
19+
### Test Command
20+
@code{.unparsed}
21+
make gentarget
22+
@endcode
23+
*/
24+
component pss_top {
25+
action root_a {
26+
list<bit [4]> nibbleList_0 = {4'b1100, 4'b0110, 4'b0011};
27+
bit [4] nibble_0_0 = 4'b0001;
28+
bit [4] nibble_0_1 = 4'b0010;
29+
bit [4] nibble_0_2 = 4'b0100;
30+
31+
exec post_solve {
32+
nibbleList_0[0] = 4'b0110;
33+
nibbleList_0[1] = nibbleList_0[2];
34+
nibbleList_0[2] |= nibbleList_0[0];
35+
36+
nibble_0_0 = nibbleList_0[0];
37+
nibble_0_1 = nibbleList_0[1];
38+
nibble_0_2 = nibbleList_0[2];
39+
}
40+
41+
exec body ASM =
42+
"""
43+
nibble_0_0 = {{nibble_0_0}} = {{nibble_0_0[3]}}{{nibble_0_0[2]}}{{nibble_0_0[1]}}{{nibble_0_0[0]}}
44+
nibble_0_1 = {{nibble_0_1}} = {{nibble_0_1[3]}}{{nibble_0_1[2]}}{{nibble_0_1[1]}}{{nibble_0_1[0]}}
45+
nibble_0_2 = {{nibble_0_2}} = {{nibble_0_2[3]}}{{nibble_0_2[2]}}{{nibble_0_2[1]}}{{nibble_0_2[0]}}
46+
""";
47+
}
48+
}
49+
50+
/**@}*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
nibble_0_0 = 6 = 0110
3+
nibble_0_1 = 3 = 0011
4+
nibble_0_2 = 7 = 0111
5+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include ${PSS_HOME}/samples/Make.vars
2+
3+
gentarget:
4+
$(PSSGEN) test.pss -o test.s -root pss_top::root_a || true
5+
6+
clean:
7+
rm -f test.s result.log

0 commit comments

Comments
 (0)