-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from rems-project/systemverilog
Systemverilog backend
- Loading branch information
Showing
51 changed files
with
4,675 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
`ifndef SAIL_LIBRARY | ||
`define SAIL_LIBRARY | ||
|
||
// The Sail unit type. | ||
typedef enum logic [0:0] {SAIL_UNIT=0} sail_unit; | ||
|
||
// The Sail zero-width bitvector. | ||
typedef enum logic [0:0] {SAIL_ZWBV=0} sail_zwbv; | ||
|
||
`ifdef SAIL_NOSTRINGS | ||
|
||
function automatic sail_unit sail_print_endline(sail_unit s); | ||
return SAIL_UNIT; | ||
endfunction // sail_print_endline | ||
|
||
function automatic sail_unit sail_prerr_endline(sail_unit s); | ||
return SAIL_UNIT; | ||
endfunction // sail_prerr_endline | ||
|
||
function automatic sail_unit sail_print(sail_unit s); | ||
return SAIL_UNIT; | ||
endfunction // sail_print | ||
|
||
function automatic sail_unit sail_prerr(sail_unit s); | ||
return SAIL_UNIT; | ||
endfunction // sail_prerr | ||
|
||
function automatic sail_unit sail_assert(bit b, sail_unit msg); | ||
return SAIL_UNIT; | ||
endfunction // sail_assert | ||
|
||
function automatic bit sail_eq_string(sail_unit s1, sail_unit s2); | ||
return 0; | ||
endfunction | ||
|
||
function automatic sail_unit sail_concat_str(sail_unit s1, sail_unit s2); | ||
return SAIL_UNIT; | ||
endfunction | ||
|
||
`else | ||
|
||
function automatic sail_unit sail_print_endline(string s); | ||
$display(s); | ||
return SAIL_UNIT; | ||
endfunction // sail_print_endline | ||
|
||
function automatic sail_unit sail_prerr_endline(string s); | ||
$display(s); | ||
return SAIL_UNIT; | ||
endfunction // sail_prerr_endline | ||
|
||
function automatic sail_unit sail_print(string s); | ||
$write(s); | ||
return SAIL_UNIT; | ||
endfunction // sail_print | ||
|
||
function automatic sail_unit sail_prerr(string s); | ||
$write(s); | ||
return SAIL_UNIT; | ||
endfunction // sail_prerr | ||
|
||
function automatic sail_unit sail_assert(bit b, string msg); | ||
if (!b) begin | ||
$display("%s", msg); | ||
end; | ||
return SAIL_UNIT; | ||
endfunction // sail_assert | ||
|
||
function automatic bit sail_eq_string(string s1, string s2); | ||
return s1 == s2; | ||
endfunction | ||
|
||
function automatic string sail_concat_str(string s1, string s2); | ||
return {s1, s2}; | ||
endfunction | ||
|
||
`endif | ||
|
||
typedef enum logic [0:0] {SAIL_REAL} sail_real; | ||
|
||
`endif // `ifndef SAIL_LIBRARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
`ifndef SAIL_MEMORY | ||
`define SAIL_MEMORY | ||
|
||
logic [7:0] sail_memory [logic [63:0]]; | ||
|
||
bit sail_tag_memory [logic [63:0]]; | ||
|
||
function automatic sail_bits sail_emulator_read_mem(logic [63:0] addrsize, sail_bits addr, sail_int n); | ||
logic [63:0] paddr; | ||
logic [SAIL_BITS_WIDTH-1:0] buffer; | ||
sail_int i; | ||
|
||
paddr = addr.bits[63:0]; | ||
|
||
for (i = n; i > 0; i = i - 1) begin | ||
buffer = buffer << 8; | ||
buffer[7:0] = sail_memory[paddr + (i[63:0] - 1)]; | ||
end | ||
|
||
return '{n[SAIL_INDEX_WIDTH-1:0] * 8, buffer}; | ||
endfunction | ||
|
||
function automatic sail_bits sail_emulator_read_mem_ifetch(logic [63:0] addrsize, sail_bits addr, sail_int n); | ||
return sail_emulator_read_mem(addrsize, addr, n); | ||
endfunction | ||
|
||
function automatic sail_bits sail_emulator_read_mem_exclusive(logic [63:0] addrsize, sail_bits addr, sail_int n); | ||
return sail_emulator_read_mem(addrsize, addr, n); | ||
endfunction | ||
|
||
function automatic bit sail_emulator_write_mem(logic [63:0] addrsize, sail_bits addr, sail_int n, sail_bits value); | ||
logic [63:0] paddr; | ||
logic [SAIL_BITS_WIDTH-1:0] buffer; | ||
sail_int i; | ||
|
||
paddr = addr.bits[63:0]; | ||
buffer = value.bits; | ||
|
||
for (i = 0; i < n; i = i + 1) begin | ||
sail_memory[paddr + i[63:0]] = buffer[7:0]; | ||
buffer = buffer >> 8; | ||
end | ||
|
||
return 1'b1; | ||
endfunction | ||
|
||
function automatic bit sail_emulator_write_mem_exclusive(logic [63:0] addrsize, sail_bits addr, sail_int n, sail_bits value); | ||
return sail_emulator_write_mem(addrsize, addr, n, value); | ||
endfunction | ||
|
||
function automatic bit sail_emulator_read_tag(logic [63:0] addrsize, sail_bits addr); | ||
logic [63:0] paddr; | ||
paddr = addr.bits[63:0]; | ||
if (sail_tag_memory.exists(paddr) == 1) | ||
return sail_tag_memory[paddr]; | ||
else | ||
return 1'b0; | ||
endfunction | ||
|
||
function automatic sail_unit sail_emulator_write_tag(logic [63:0] addrsize, sail_bits addr, bit tag); | ||
logic [63:0] paddr; | ||
paddr = addr.bits[63:0]; | ||
sail_tag_memory[paddr] = tag; | ||
return SAIL_UNIT; | ||
endfunction | ||
|
||
`endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
version: "0.16" | ||
synopsis: "Sail to Systemverilog translation" | ||
maintainer: ["Sail Devs <[email protected]>"] | ||
authors: [ | ||
"Alasdair Armstrong" | ||
"Thomas Bauereiss" | ||
"Brian Campbell" | ||
"Shaked Flur" | ||
"Jonathan French" | ||
"Kathy Gray" | ||
"Robert Norton" | ||
"Christopher Pulte" | ||
"Peter Sewell" | ||
"Mark Wassell" | ||
] | ||
license: "BSD-2-Clause" | ||
homepage: "https://github.com/rems-project/sail" | ||
bug-reports: "https://github.com/rems-project/sail/issues" | ||
depends: [ | ||
"dune" {>= "3.0"} | ||
"libsail" {= version} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"--promote-install-files=false" | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
["dune" "install" "-p" name "--create-install-files" name] | ||
] | ||
dev-repo: "git+https://github.com/rems-project/sail.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.