From: Sebastien Bourdeauducq Date: Wed, 8 May 2013 18:58:27 +0000 (+0200) Subject: cif: do not generate write function for CSRStatus X-Git-Tag: 24jan2021_ls180~2946 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=89dbc37ecebe2b76bbeaa245c937fe529fe23983;p=litex.git cif: do not generate write function for CSRStatus --- diff --git a/cif.py b/cif.py index a8aca187..ace7b2af 100644 --- a/cif.py +++ b/cif.py @@ -1,6 +1,8 @@ from operator import itemgetter import re +from migen.bank.description import CSRStatus + def get_macros(filename): f = open(filename, "r") r = {} @@ -10,7 +12,7 @@ def get_macros(filename): r[match.group(1)] = match.group(2) return r -def _get_rw_functions(reg_name, reg_base, size): +def _get_rw_functions(reg_name, reg_base, size, read_only): r = "" if size > 8: raise NotImplementedError("Register too large") @@ -32,15 +34,16 @@ def _get_rw_functions(reg_name, reg_base, size): else: r += "\treturn MMPTR("+hex(reg_base)+");\n}\n" - r += "static inline void "+reg_name+"_write("+ctype+" value) {\n" - for byte in range(size): - shift = (size-byte-1)*8 - if shift: - value_shifted = "value >> "+str(shift) - else: - value_shifted = "value" - r += "\tMMPTR("+hex(reg_base+4*byte)+") = "+value_shifted+";\n" - r += "}\n" + if not read_only: + r += "static inline void "+reg_name+"_write("+ctype+" value) {\n" + for byte in range(size): + shift = (size-byte-1)*8 + if shift: + value_shifted = "value >> "+str(shift) + else: + value_shifted = "value" + r += "\tMMPTR("+hex(reg_base+4*byte)+") = "+value_shifted+";\n" + r += "}\n" return r def get_csr_header(csr_base, bank_array, interrupt_map): @@ -51,7 +54,7 @@ def get_csr_header(csr_base, bank_array, interrupt_map): r += "#define "+name.upper()+"_BASE "+hex(reg_base)+"\n" for csr in csrs: nr = (csr.size + 7)//8 - r += _get_rw_functions(name + "_" + csr.name, reg_base, nr) + r += _get_rw_functions(name + "_" + csr.name, reg_base, nr, isinstance(csr, CSRStatus)) reg_base += 4*nr try: interrupt_nr = interrupt_map[name]