[Libre-soc-dev] Quick help
Cole Poirier
colepoirier at gmail.com
Fri Sep 25 21:24:25 BST 2020
Hi Luke,
Having trouble understanding word select.
Trying to ensure the correctness of my translation of the following
function from icache.vhdl:
```
-- Read the instruction word for the given address in the current cache row
function read_insn_word(addr: std_ulogic_vector(63 downto 0);
data: cache_row_t) return std_ulogic_vector is
variable word: integer range 0 to INSN_PER_ROW-1;
begin
word := to_integer(unsigned(addr(INSN_BITS+2-1 downto 2)));
return data(31+word*32 downto word*32);
end;
```
I currently have it translated like so:
```
# Read the instruction word for the given address
# in the current cache row
def read_insn_word(addr, data):
word = addr[2:INSN_BITS+2]
return data.word_select(word, 32)
```
Is this correct, or should I be using 'word*32' or 'word + 31' ?
Thanks for your help, as always :)
Cole
More information about the Libre-soc-dev
mailing list