From a03532cc2d2318b7c26d1ce67cd866ce16f2470d Mon Sep 17 00:00:00 2001
From: Kia <kia@special-circumstanc.es>
Date: Tue, 9 Mar 2021 21:02:45 -0700
Subject: [PATCH] unoptimized_lr/simple_lr_automaton.py

---
 unoptimized_lr/simple_lr_automaton.py | 43 +++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/unoptimized_lr/simple_lr_automaton.py b/unoptimized_lr/simple_lr_automaton.py
index 6c764a3..a3d9645 100644
--- a/unoptimized_lr/simple_lr_automaton.py
+++ b/unoptimized_lr/simple_lr_automaton.py
@@ -20,6 +20,49 @@ from functools import reduce
 
 
 
+# There are several classes of parameters for this parser:
+# 1) Parameters based only on the language (and the generated LR automaton):
+#        * NTerminal:    Number of terminals
+#        * NNonterminal: Number of nonterminals
+#        * NStates:      Number of states in the LR automaton
+#        * NRules:       Number of rules
+#
+# From those, we derive these widths for internal buses and registers,
+# where log_2 determines the numbers of bits necessary to represent all possible
+# values for each type:
+#
+# log_2(NTerminal) =    WTerminal
+# log_2(NNonterminal) = WNonterminal
+# log_2(NStates)=       WStates
+# log_2(NRules)=        WRules
+# and WItem = max(WTerminal, WNonterminal); since there are locations where
+# nonterminals and terminals alike must be processed/stored by the same mechanisms
+#
+#
+# 2) Parameters based on expected use cases:
+#        * NStackItems:   Parse stack depth.
+#        * NLongestParse: The length of the longest possible parse tree
+#
+# In the general case, it is impossible to determine these for a given language.
+# Even with a simple expression-term-factor grammar, it's possible to reach arbitrary
+# depth of parse stack with arbitrary numbers of OPENPARENs, and likewise for the
+# length of the longest parse tree.
+#
+# The length of the longest parse tree is significant because our parse tree
+# serialization scheme uses absolute indices to link different nonterminals together
+# and the width of those indices is fixed at synthesis-time.
+#
+#
+# 3) Parameters based on the targeted hardware, namely, the
+#    widths and depths of block RAMs used for:
+#        * Shift/reduce table
+#        * GOTO table
+#        * Parse Stack
+#        * Sideband/index stack
+#        * Serialization memory
+
+
+
 
 
 class LRAutomaton(Elaboratable):
-- 
GitLab