-
Notifications
You must be signed in to change notification settings - Fork 219
Big endianness Support added #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 10 commits
db63dac
b7a06e3
3930145
89d2664
758d9d0
cd944ee
1caf3bc
e14c7d0
bc344ee
c39162f
48a6636
daa2d01
552b0e3
6c2ab4d
cce02b1
446bce4
56dff58
91e7d86
1ecd7c7
05b7087
5ff2c37
f243b51
6c0ae67
8444a81
71d4c1d
456524b
cfba783
d528507
89f3768
33752f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,17 @@ function write_kind_of_flags (aq : bool, rl : bool, con : bool) -> write_kind = | |
(true, false, true) => throw(Error_not_implemented("sc.aq")) | ||
} | ||
|
||
function is_big_endian(typ : AccessType(ext_access_type)) -> bool = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not have this be something like
Then you can replace all of the uses of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! I will implement this |
||
match effectivePrivilege(typ, mstatus, cur_privilege) { | ||
Machine => bits_to_bool(mstatus[MBE]), | ||
Supervisor => bits_to_bool(mstatus[SBE]), | ||
User => bits_to_bool(mstatus[UBE]), | ||
} | ||
} | ||
|
||
Timmmm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
function endianness_conversion forall 'n, 0 < 'n <= max_mem_access . (data : bits(8 * 'n), ac : AccessType(ext_access_type)) -> bits(8 * 'n) = | ||
if is_big_endian(ac) & not(ac == Execute()) then reverse_endianness(data) else data | ||
|
||
jordancarlin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// only used for actual memory regions, to avoid MMIO effects | ||
function phys_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), paddr : physaddr, width : int('n), aq : bool, rl: bool, res : bool, meta : bool) -> MemoryOpResult((bits(8 * 'n), mem_meta)) = { | ||
let result = (match read_kind_of_flags(aq, rl, res) { | ||
|
@@ -73,9 +84,11 @@ function phys_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext | |
(Execute(), None()) => Err(E_Fetch_Access_Fault()), | ||
(Read(Data), None()) => Err(E_Load_Access_Fault()), | ||
(_, None()) => Err(E_SAMO_Access_Fault()), | ||
(_, Some(v, m)) => { if get_config_print_mem() | ||
then print_mem("mem[" ^ to_str(t) ^ "," ^ BitStr(physaddr_bits(paddr)) ^ "] -> " ^ BitStr(v)); | ||
Ok(v, m) } | ||
(_, Some(v, m)) => { | ||
let v = endianness_conversion(v, t); | ||
MuhammadHammad001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if get_config_print_mem() | ||
then print_mem("mem[" ^ to_str(t) ^ "," ^ BitStr(physaddr_bits(paddr)) ^ "] -> " ^ BitStr(v)); | ||
Ok(v, m) } | ||
} | ||
} | ||
|
||
|
@@ -196,6 +209,7 @@ $endif | |
|
||
// only used for actual memory regions, to avoid MMIO effects | ||
function phys_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk : write_kind, paddr : physaddr, width : int('n), data : bits(8 * 'n), meta : mem_meta) -> MemoryOpResult(bool) = { | ||
let data = endianness_conversion(data, Write()); | ||
let result = write_ram(wk, paddr, width, data, meta); | ||
if get_config_print_mem() | ||
then print_mem("mem[" ^ BitStr(physaddr_bits(paddr)) ^ "] <- " ^ BitStr(data)); | ||
|
Uh oh!
There was an error while loading. Please reload this page.