Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cif: do not generate write function for CSRStatus

  • Loading branch information...
commit 89dbc37ecebe2b76bbeaa245c937fe529fe23983 1 parent 8e76c96
Sébastien Bourdeauducq authored May 08, 2013

Showing 1 changed file with 14 additions and 11 deletions. Show diff stats Hide diff stats

  1. 25  cif.py
25  cif.py
... ...
@@ -1,6 +1,8 @@
1 1
 from operator import itemgetter
2 2
 import re
3 3
 
  4
+from migen.bank.description import CSRStatus
  5
+
4 6
 def get_macros(filename):
5 7
 	f = open(filename, "r")
6 8
 	r = {}
@@ -10,7 +12,7 @@ def get_macros(filename):
10 12
 			r[match.group(1)] = match.group(2)
11 13
 	return r
12 14
 
13  
-def _get_rw_functions(reg_name, reg_base, size):
  15
+def _get_rw_functions(reg_name, reg_base, size, read_only):
14 16
 	r = ""
15 17
 	if size > 8:
16 18
 		raise NotImplementedError("Register too large")
@@ -32,15 +34,16 @@ def _get_rw_functions(reg_name, reg_base, size):
32 34
 	else:
33 35
 		r += "\treturn MMPTR("+hex(reg_base)+");\n}\n"
34 36
 
35  
-	r += "static inline void "+reg_name+"_write("+ctype+" value) {\n"
36  
-	for byte in range(size):
37  
-		shift = (size-byte-1)*8
38  
-		if shift:
39  
-			value_shifted = "value >> "+str(shift)
40  
-		else:
41  
-			value_shifted = "value"
42  
-		r += "\tMMPTR("+hex(reg_base+4*byte)+") = "+value_shifted+";\n"
43  
-	r += "}\n"
  37
+	if not read_only:
  38
+		r += "static inline void "+reg_name+"_write("+ctype+" value) {\n"
  39
+		for byte in range(size):
  40
+			shift = (size-byte-1)*8
  41
+			if shift:
  42
+				value_shifted = "value >> "+str(shift)
  43
+			else:
  44
+				value_shifted = "value"
  45
+			r += "\tMMPTR("+hex(reg_base+4*byte)+") = "+value_shifted+";\n"
  46
+		r += "}\n"
44 47
 	return r
45 48
 
46 49
 def get_csr_header(csr_base, bank_array, interrupt_map):
@@ -51,7 +54,7 @@ def get_csr_header(csr_base, bank_array, interrupt_map):
51 54
 		r += "#define "+name.upper()+"_BASE "+hex(reg_base)+"\n"
52 55
 		for csr in csrs:
53 56
 			nr = (csr.size + 7)//8
54  
-			r += _get_rw_functions(name + "_" + csr.name, reg_base, nr)
  57
+			r += _get_rw_functions(name + "_" + csr.name, reg_base, nr, isinstance(csr, CSRStatus))
55 58
 			reg_base += 4*nr
56 59
 		try:
57 60
 			interrupt_nr = interrupt_map[name]

0 notes on commit 89dbc37

Please sign in to comment.
Something went wrong with that request. Please try again.