From WikiChip
Module:chip
Revision as of 03:59, 1 January 2020 by David (talk | contribs)

To add this template, simple add
{{chip}}
to the page and save. The chip infobox will have a small [Edit Values] button at the top-right corner which can be used to add values using a form.
local p = {}
local origArgs

function p.add_file_prefix(str)
  if string.match(string.lower(str), '^file:') then
    return str
  else
    return 'File:' .. str
  end
end

function p.add_separator(box, title)
  box:tag('tr')
           :tag('td')
           :attr('class', 'header')
           :attr('colspan', '2')
           :wikitext(title)
end

function p.add_entry(value, right)
  local e = mw.html.create('tr')
  e:tag('td')
    :attr('class', 'label')
    :wikitext(value)
  e:node(right)
  return e   
end

function has_arg(name)
	-- The argument can exist and be empty or not exist at all
	return string.len(origArgs[name] or '') > 0
end

function arg(name)
	if has_arg(name) then
		return origArgs[name]
	end
	return ''
end

function p.set_val(prop, val)
	p.frame:preprocess('{{#set: ' .. prop .. '=' .. val .. '}}')	
end

function p.chip(frame)
	
	p.frame = frame
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame.args
    end
    
    
    local infobox = mw.html.create('table')
    
    -- by default it's a microprocessor
    local chip_type = 'microprocessor'
    if has_arg('chip type') then
		chip_type = arg('chip type')
	end
	
	-- define it as an instance of that chip
	p.set_val('instance of', chip_type)
	
	-- same for category
    infobox:wikitext('[[Category:all ' .. chip_type .. ' models]]')
	

    infobox
        :attr('class', 'infobox')
        
    infobox
    	:tag('tr')
			:tag('td'):attr('colspan', '2')
			:tag('small'):attr('style', 'float: left; font-weight: bold;')
            :wikitext('[[Special:FormEdit/chip/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')

    -- header
    if has_arg('name') then
		infobox
			:tag('tr')
			:tag('td')
			:attr('class', 'header-main')
			:attr('colspan', '2')
			:wikitext(arg('name'))
		p.set_val('name', arg('name'))
    end

    -- image
	if has_arg('image') then
		local image = p.add_file_prefix(arg('image'))
		local image_size = has_arg('image size') and arg('image size') or "200px" 
		infobox
		:tag('tr')
		  :tag('td')
		    :attr('style', 'text-align: center;')
		    :attr('colspan', '2')
		    -- make sure it's the ogimage
		    :wikitext('[[' .. image .. '|link=|class=wikichip_ogimage|' .. image_size .. ']]')
		
		p.set_val('main image', image)

      -- add a caption, if provided
      if has_arg('caption') then
		infobox
			:tag('tr')
			:tag('td')
			:attr('style', 'text-align: center;')
			:attr('colspan', '2')
			:wikitext(arg('caption'))
		p.set_val('main image caption', arg('caption'))
      end
	elseif not has_arg('no image') then
      infobox
        :tag('tr')
          :tag('td')
            :attr('style', 'text-align: center;')
            :attr('colspan', '2')
            :wikitext('[[File:no photo (ic).svg|link=|200px]]')
    end
    
    

    -- image
	if has_arg('image 2') then
		local image = p.add_file_prefix(arg('image 2'))
		local image_size = has_arg('image 2 size') and arg('image 2 size') or "200px" 
		infobox
		:tag('tr')
		  :tag('td')
		    :attr('style', 'text-align: center;')
		    :attr('colspan', '2')
		    -- make sure it's the ogimage
		    :wikitext('[[' .. image .. '|link=|' .. image_size .. ']]')
	end

    -- ####################################################################
    -- some general info first
    p.add_separator(infobox, 'General Info')
    
    -- designer
    if has_arg('designer') then
      	local designers = mw.html.create('td'):attr('style', 'width: 99%;')
      	p.set_val('designer', arg('designer'))
      	designers:wikitext('[[' .. arg('designer') .. ']]' ..
      				'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
		if has_arg('microarch') then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) ..
					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
		end
		
		for i = 2, 10 do
			if has_arg('microarch ' .. i) then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) ..
			  		' based on ' .. mw.ustring.lower(arg('microarch ' .. i)) .. ']]')
			end
		end
      
      for i = 2, 10 do
      	if not has_arg('designer ' .. i) then break end
      		p.set_val('designer', arg('designer ' .. i))
      		designers:wikitext(',<br>[[' .. arg('designer ' .. i) .. ']]' ..
      				'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
      			
		if has_arg('microarch') then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
		end
		
		for i = 2, 10 do
			if has_arg('microarch ' .. i) then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
			  		' based on ' .. mw.ustring.lower(arg('microarch ' .. i)) .. ']]')
			end
		end
      end
   	  infobox:node(p.add_entry('Designer', designers))
	end
    
    -- manufacturer
    if has_arg('manufacturer') then
      local manufacturers = '[[' .. arg('manufacturer') .. ']]' ..
      		'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
  		p.set_val('manufacturer', arg('manufacturer'))
      		
      for i = 2, 10 do
      	if not has_arg('manufacturer ' .. i) then break end
      	manufacturers = manufacturers .. ', [[' .. arg('manufacturer ' .. i) .. ']]' ..
      		'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
  		p.set_val('manufacturer', arg('manufacturer ' .. i))
      end
      
   	  infobox:node(p.add_entry('Manufacturer', mw.html.create('td'):wikitext(manufacturers)))
	end
	
	-- model number
	if has_arg('model number') then
		p.set_val('model number', arg('model number'))
	  	infobox:node(p.add_entry('Model Number', mw.html.create('td'):attr('style', 'width: 99%;'):wikitext(arg('model number'))))
	end
    
    -- part number
    if has_arg('part number') then
		p.set_val('part number', arg('part number'))
		local parts = arg('part number')
		for i = 2, 10 do
			if not has_arg('part number ' .. i) then break end
			p.set_val('part number', arg('part number ' .. i))
			parts = parts .. ',<br> ' .. arg('part number ' .. i)
		end
		infobox:node(p.add_entry('Part Number', mw.html.create('td'):wikitext(parts)))
	end
    
    -- s-spec
    if has_arg('s-spec') or has_arg('s-spec qs') then
      local sspec = ''
      if has_arg('s-spec') then
      	p.set_val('s-spec', arg('s-spec'))
        sspec = arg('s-spec')
        for i = 2, 30 do
        	if not has_arg('s-spec ' .. i) then break end
      		p.set_val('s-spec', arg('s-spec ' .. i))
        	sspec = sspec .. ', ' .. arg('s-spec ' .. i)
        end
      end
      if has_arg('s-spec qs') then
      	if has_arg('s-spec') then sspec = sspec .. '<br>' end
      	p.set_val('s-spec (qs)', arg('s-spec qs'))
        sspec = sspec .. arg('s-spec qs') .. ' ([[qualification sample|QS]])'
        for i = 2, 30 do
        	if not has_arg('s-spec qs ' .. i) then break end
      		p.set_val('s-spec (qs)', arg('s-spec qs ' .. i))
        	sspec = sspec .. ', ' .. arg('s-spec qs ' .. i) .. ' ([[qualification sample|QS]])'
        end
      end
   	  infobox:node(p.add_entry('S-Spec', mw.html.create('td'):wikitext(sspec)))
	end
	
	-- market segment
    if has_arg('market') then
		p.set_val('market segment', arg('market'))
      	local markets = mw.html.create('td'):wikitext(arg('market'))
      	for i = 2, 5 do
  			if not has_arg('market ' .. i) then break end
			p.set_val('market segment', arg('market ' .. i))
      		markets:wikitext(', ' .. arg('market ' .. i))
      	end
   	  	infobox:node(p.add_entry('Market', markets))
	end
	
	-- release date
	if has_arg('first launched') or has_arg('first announced') then
	  local release = mw.html.create('td')
	  if has_arg('first announced') then
	  	p.set_val('first announced', arg('first announced'))
	    release:wikitext(arg('first announced') .. ' (announced)')
	  end
	  if has_arg('first launched') then
	  	if has_arg('first announced') then
	  	  release:wikitext('<br>')	
  		end
  		p.set_val('first launched', arg('first launched'))
	    release:wikitext(arg('first launched') .. ' (launched)')
	  end
	  infobox:node(p.add_entry('Introduction', release))
	end
	
	-- EOL
	if has_arg('last order') or has_arg('last shipment') then
	  local release = mw.html.create('td')
	  if has_arg('last order') then
	  	p.set_val('last order', arg('last order'))
	    release:wikitext(arg('last order') .. ' (last order)')
	  end
	  if has_arg('last shipment') then
	  	if has_arg('last order') then
	  	  release:wikitext('<br>')	
  		end
  		p.set_val('last shipment', arg('last shipment'))
	    release:wikitext(arg('last shipment') .. ' (last shipment)')
	  end
	  infobox:node(p.add_entry('End-of-life', release))
	end
	
	-- release price
	if has_arg('release price') or has_arg('release price (box)') or has_arg('release price (tray)') then
		local release_price = ''
		
		if has_arg('release price') then
			release_price = arg('release price')
			p.set_val('release price', arg('release price'))
		end
		if has_arg('release price (tray)') then
			if release_price ~= "" then release_price = release_price .. '<br>' end
			release_price = release_price .. arg('release price (tray)') .. ' (tray)'
			p.set_val('release price (tray)', arg('release price (tray)'))
			p.set_val('release price', arg('release price (tray)')) --add it there as well
		end
		if has_arg('release price (box)') then
			if release_price ~= "" then release_price = release_price .. '<br>' end
			release_price = release_price .. arg('release price (box)') .. ' (box)'
			p.set_val('release price (box)', arg('release price (box)'))
			p.set_val('release price', arg('release price (box)')) --add it there as well
		end
		
		infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext(release_price)))
	end
	
	-- Shop links

	
	
	

    -- ####################################################################
    -- Generla Specs 
    
    -- early checks
    local hasTurbo = false
    for i = 1, 42 do
    	if has_arg('turbo frequency' .. i) then hasTurbo = true break end
	end
	
	
    -- some general specs
	if has_arg('family') or has_arg('series') or has_arg('locked') or 
		has_arg('frequency') or hasTurbo or has_arg('turbo frequency') or 
		has_arg('bus type') or has_arg('bus speed') or has_arg('bus rate') or
		has_arg('clock multiplier') or has_arg('cpuid') then
    	p.add_separator(infobox, 'General Specs')
    end
	
	-- family
	if has_arg('family') then
		local families = mw.html.create('td')
		
		p.set_val('family', arg('family'))
		families:wikitext(
	  				'[[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family')) .. '|' .. arg('family') .. ']]')

		for i = 2, 10 do
			if not has_arg('family ' .. i) then break end
			p.set_val('family', arg('family ' .. i))
		
			families:wikitext(
  				', [[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family ' .. i)) .. '|' .. arg('family ' .. i) .. ']]')
		end
		
		
		infobox:node(p.add_entry('Family', families))
	end
	
	-- series
	if has_arg('series') then
		p.set_val('series', arg('series'))
	  	infobox:node(p.add_entry('Series', mw.html.create('td'):wikitext(arg('series'))))
	end
	
	-- locked?
	if has_arg('locked') then
		p.set_val('has locked clock multiplier', arg('locked'))
		infobox:node(p.add_entry('Locked', mw.html.create('td'):wikitext(arg('locked'))))
	end
    
    -- frequency
    if has_arg('frequency') then
		p.set_val('base frequency', arg('frequency'))
		local frequencies = mw.html.create('td'):wikitext( arg('frequency'))
		for i = 2, 10 do
			if not has_arg('frequency ' .. i) then break end
			p.set_val('base frequency', arg('frequency ' .. i))
			frequencies:wikitext(', ' .. arg('frequency ' .. i))
		end
		infobox:node(p.add_entry('Frequency', frequencies))
	end
    
    -- lone turbo
    if has_arg('turbo frequency') then
		local turbo = mw.html.create('td')
		p.set_val('turbo frequency', arg('turbo frequency'))
		turbo:wikitext(arg('turbo frequency'))
		infobox:node(p.add_entry('Turbo Frequency', turbo))
	end
	
    -- turbo frequency
    if hasTurbo then
      local turbo = mw.html.create('td')
      for i = 1, 42 do
      	--sometimes turbo is not specified for odd-cores, so skip 2 each time, so we can't break
        --if not has_arg('turbo frequency' .. i) then break end
        if has_arg('turbo frequency' .. i) then
        	local s = i > 1 and 's' or ''
        	local br = i > 1 and ',<br>' or ''
        	p.set_val('turbo frequency (' .. i .. ' core' .. s .. ')', arg('turbo frequency' .. i))
			turbo:wikitext(br .. arg('turbo frequency' .. i) .. ' (' .. i .. ' core' .. s .. ')')
      	end
      end
   	  infobox:node(p.add_entry('Turbo Frequency', turbo))
	end
	
	-- bus type
	if has_arg('bus type') then
		p.set_val('bus type', arg('bus type'))
		infobox:node(p.add_entry('Bus type', mw.html.create('td'):wikitext(arg('bus type'))))
	end
	
	-- bus speed
	if has_arg('bus speed') then
		p.set_val('bus speed', arg('bus speed'))
		infobox:node(p.add_entry('Bus speed', mw.html.create('td'):wikitext(arg('bus speed'))))
	end
	
	-- bus rate
	if has_arg('bus rate') then
		local links = ''
		if has_arg('bus links') then
			p.set_val('bus links', arg('bus links'))
			links = arg('bus links') .. '&nbsp;×&nbsp;'
		end
		p.set_val('bus rate', arg('bus rate'))
		infobox:node(p.add_entry('Bus rate', mw.html.create('td'):wikitext(links .. arg('bus rate'))))
	end
	
	-- clock mult
	if has_arg('clock multiplier') then
		p.set_val('clock multiplier', arg('clock multiplier'))
		infobox:node(p.add_entry('Clock multiplier', mw.html.create('td'):wikitext(arg('clock multiplier'))))
	end
	
	-- CPUID
    if has_arg('cpuid') then
		p.set_val('cpuid', arg('cpuid'))
		local cpuid = mw.html.create('td'):wikitext(arg('cpuid'))
		for i = 2, 10 do
			if not has_arg('cpuid ' .. i) then break end
			p.set_val('cpuid', arg('cpuid ' .. i))
			cpuid:wikitext(', ' .. arg('cpuid ' .. i))
		end
   	  infobox:node(p.add_entry('CPUID', cpuid))
	end
	
	
    -- ####################################################################
    -- Neuromorphic Chip 
    
    -- some general specs
	if has_arg('neuron count') or has_arg('synapse count') then
    	p.add_separator(infobox, 'Neuromorphic Specs')
    end
    
	-- neurons count
	if has_arg('neuron count') then
		p.set_val('neuron count', arg('neuron count'))
	  infobox:node(p.add_entry('Neurons', mw.html.create('td'):wikitext(arg('neuron count'))))
	end

	-- synapse count
	if has_arg('synapse count') then
		p.set_val('synapse count', arg('synapse count'))
	  infobox:node(p.add_entry('Synapses', mw.html.create('td'):wikitext(arg('synapse count'))))
	end

    -- ####################################################################
    -- some general info first
    p.add_separator(infobox, 'Microarchitecture')
	
	-- ISA
    if has_arg('isa') or has_arg('isa family') then
  		p.set_val('isa', arg('isa'))
      	local isa = mw.html.create('td'):wikitext(arg('isa'))
		if has_arg('isa family') then
			p.set_val('isa family', arg('isa family'))
			isa:wikitext('&nbsp;(' .. arg('isa family') .. ')')
		end
      	for i = 2, 10 do
      		if not has_arg('isa ' .. i) then break end
      		p.set_val('isa', arg('isa ' .. i))
      		isa:wikitext(', ' .. arg('isa ' .. i))
			if has_arg('isa ' .. i .. ' family') then
				p.set_val('isa family', arg('isa ' .. i .. ' family'))
				isa:wikitext('&nbsp;(' .. arg('isa ' .. i .. ' family') .. ')')
			end
      	end
   	  infobox:node(p.add_entry('ISA', isa))
	end
	
	-- microarch
    if has_arg('microarch') then
      local microarchs = mw.html.create('td')
      p.set_val('microarchitecture', arg('microarch'))
      microarchs:wikitext('[[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
      		mw.ustring.lower(arg('microarch')) .. '|' .. arg('microarch') .. ']]')
      for i = 2, 10 do
      	if not has_arg('microarch ' .. i) then break end
      	p.set_val('microarchitecture', arg('microarch ' .. i))
        microarchs:wikitext(', [[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
      		mw.ustring.lower(arg('microarch ' .. i)) .. '|' .. arg('microarch ' .. i) .. ']]')
      end
   	  infobox:node(p.add_entry('Microarchitecture', microarchs))
	end
	
	-- platform
	if has_arg('platform') then
		p.set_val('platform', arg('platform'))
		infobox:node(p.add_entry('Platform', mw.html.create('td'):wikitext(arg('platform'))))
	end
	
	-- chipset
    if has_arg('chipset') then
		p.set_val('chipset', arg('chipset'))
		local chipset = mw.html.create('td'):wikitext(arg('chipset'))
		for i = 2, 10 do
			if not has_arg('chipset ' .. i) then break end
			p.set_val('chipset', arg('chipset ' .. i))
			chipset:wikitext(', ' .. arg('chipset ' .. i))
      	end
		infobox:node(p.add_entry('Chipset', chipset))
	end
	
	-- core name
    if has_arg('core name') then
		p.set_val('core name', arg('core name'))
      	local core_name = mw.html.create('td'):wikitext(
      				'[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name')) .. '|' ..
      				arg('core name') .. ']]')
      for i = 2, 10 do
      	if not has_arg('core name ' .. i) then break end
      	p.set_val('core name', arg('core name ' .. i))
      	core_name:wikitext(', ' ..
      				'[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name ' .. i)) .. '|' ..
      				arg('core name ' .. i) .. ']]')
      end
   	  infobox:node(p.add_entry('Core Name', core_name))
	end
	
	-- core family
    if has_arg('core family') then
    	p.set_val('core family', arg('core family'))
      	local corefam = mw.html.create('td'):wikitext(arg('core family'))
      for i = 2, 10 do
      	if not has_arg('core family ' .. i) then break end
      	p.set_val('core family', arg('core family ' .. i))
      	corefam:wikitext(', ' .. arg('core family ' .. i))
      end
   	  infobox:node(p.add_entry('Core Family', corefam))
	end
	
	-- core model
    if has_arg('core model') then
    	p.set_val('core model', arg('core model'))
		local coremodel = mw.html.create('td'):wikitext(arg('core model'))
		for i = 2, 10 do
			if not has_arg('core model ' .. i) then break end
    		p.set_val('core model', arg('core model ' .. i))
			coremodel:wikitext(', ' .. arg('core model ' .. i))
		end
		 infobox:node(p.add_entry('Core Model', coremodel))
	end
	
	-- core stepping
    if has_arg('core stepping') then
    	p.set_val('core stepping', arg('core stepping'))
		local corestep = mw.html.create('td'):wikitext(arg('core stepping'))
		for i = 2, 10 do
			if not has_arg('core stepping ' .. i) then break end
    		p.set_val('core stepping', arg('core stepping ' .. i))
			corestep:wikitext(', ' .. arg('core stepping ' .. i))
		end
		infobox:node(p.add_entry('Core Stepping', corestep))
	end
	
	-- process
    if has_arg('process') then
		p.set_val('process', arg('process'))
      	local process = mw.html.create('td'):wikitext('[[' .. arg('process') .. ' process|' .. arg('process') .. ']]')
      	for i = 2, 10 do
      		if not has_arg('process ' .. i) then break end
			p.set_val('process', arg('process ' .. i))
      		process:wikitext(', ' .. '[[' .. arg('process ' .. i) .. ' process|' .. arg('process ' .. i) .. ']]')
      	end
   	  	infobox:node(p.add_entry('Process', process))
	end
	
	-- Transistors
	if has_arg('transistors') then
		p.set_val('transistor count', arg('transistors'))
	  	infobox:node(p.add_entry('Transistors', mw.html.create('td'):wikitext(arg('transistors'))))
	end
	
	-- Technology
	if has_arg('technology') then
		p.set_val('technology', arg('technology'))
	  	infobox:node(p.add_entry('Technology', mw.html.create('td'):wikitext(arg('technology'))))
	end
	
	-- die size
	if has_arg('die area') or has_arg('die size') then
		local die
		if has_arg('die size') then
			p.set_val('die area', arg('die size'))
      		die = mw.html.create('td'):wikitext(arg('die size'))
		else
			p.set_val('die area', arg('die area'))
			die = mw.html.create('td'):wikitext(arg('die area'))
		end
		if has_arg('die length') and has_arg('die width') then
			p.set_val('die length', arg('die length'))
			p.set_val('die width', arg('die width'))
			die:wikitext('<br>' .. arg('die length') .. ' × ' .. arg('die width'))	
		end
	  	infobox:node(p.add_entry('Die', die))
	end
	
	if has_arg('mcp') then
		p.set_val('is multi-chip package', arg('mcp'))
  		mcp = mw.html.create('td'):wikitext(arg('mcp'))
		if has_arg('die count') then
			p.set_val('die count', arg('die count'))
      		mcp:wikitext(' (' .. arg('die count') .. ' dies)')
		end
	  	infobox:node(p.add_entry('MCP', mcp))
	end
	
	-- word size
	if has_arg('word size') then
		p.set_val('word size', arg('word size'))
		infobox:node(p.add_entry('Word Size', mw.html.create('td'):wikitext(arg('word size'))))
	end
	
	-- core count
	if has_arg('core count') then
		p.set_val('core count', arg('core count'))
	  infobox:node(p.add_entry('Cores', mw.html.create('td'):wikitext(arg('core count'))))
	end
	
	-- thread count
	if has_arg('thread count') then
		p.set_val('thread count', arg('thread count'))
	  infobox:node(p.add_entry('Threads', mw.html.create('td'):wikitext(arg('thread count'))))
	end
	
	-- max memory
	if has_arg('max memory') then
		p.set_val('max memory', arg('max memory'))
		infobox:node(p.add_entry('Max Memory', mw.html.create('td'):wikitext(arg('max memory'))))
	end
	
	-- max memory addr
	if has_arg('max memory addr') then
		p.set_val('max memory address', arg('max memory addr'))
	  infobox:node(p.add_entry('Max Address Mem', mw.html.create('td'):wikitext(arg('max memory addr'))))
	end
	
	
    -- ####################################################################
    -- Multiprocessing
    if has_arg('max cpus') or has_arg('smp interconnect')
    	 or has_arg('smp interconnect links') 
    	 or has_arg('smp interconnect rate') then
		p.add_separator(infobox, 'Multiprocessing')
	end
	
	-- max cpus
	if has_arg('max cpus') then
		local type = tonumber(arg('max cpus')) == 1 and ' (Uniprocessor)' or ' (Multiprocessor)'
		p.set_val('max cpu count', arg('max cpus'))
		p.set_val('smp max ways', arg('max cpus'))
		infobox:node(p.add_entry('Max SMP', mw.html.create('td'):wikitext(arg('max cpus') .. '-Way' .. type)))
	end
	
	-- smp interconnect
	if has_arg('smp interconnect') then
		p.set_val('smp interconnect', arg('smp interconnect'))
		infobox:node(p.add_entry('Interconnect', mw.html.create('td'):wikitext(arg('smp interconnect'))))
	end
	
	-- smp interconnect links
	if has_arg('smp interconnect links') then
		p.set_val('smp interconnect links', arg('smp interconnect links'))
		infobox:node(p.add_entry('Interconnect Links', mw.html.create('td'):wikitext(arg('smp interconnect links'))))
	end
	
	-- smp interconnect rate
	if has_arg('smp interconnect rate') then
		p.set_val('smp interconnect rate', arg('smp interconnect rate'))
		infobox:node(p.add_entry('Interconnect Rate', mw.html.create('td'):wikitext(arg('smp interconnect rate'))))
	end

    -- ####################################################################
    -- Electrical
    if has_arg('power') or has_arg('average power') or has_arg('idle power')
    	or has_arg('v core') or has_arg('v io') or has_arg('sdp') or has_arg('tdp')
    	or has_arg('tdp typical') or has_arg('ctdp down') or has_arg('ctdp down frequency')
		or has_arg('ctdp up') or has_arg('ctdp up frequency')
		or has_arg('temp min') or has_arg('tjunc min')
		or has_arg('tcase min') or has_arg('tstorage min') or has_arg('tambient min') then
		p.add_separator(infobox, 'Electrical')
    end
	
	-- power
	if has_arg('power') then
		p.set_val('power dissipation', arg('power'))
	  infobox:node(p.add_entry('Power dissipation', mw.html.create('td'):wikitext(arg('power'))))
	end
	
	-- average power
	if has_arg('average power') then
		p.set_val('power dissipation (average)', arg('average power'))
	  infobox:node(p.add_entry('power dissipation (average)', mw.html.create('td'):wikitext(arg('average power'))))
	end
	
	-- power
	if has_arg('idle power') then
		p.set_val('power dissipation (idle)', arg('idle power'))
		infobox:node(p.add_entry('Power (idle)', mw.html.create('td'):wikitext(arg('idle power'))))
	end
	
	-- vcore
	if has_arg('v core') then
		p.set_val('core voltage', arg('v core'))
		local vcore =  mw.html.create('td'):wikitext(arg('v core'))
		if has_arg('v core tolerance') then
			p.set_val('core voltage tolerance', arg('v core tolerance'))
			vcore:wikitext(' ± ' .. arg('v core tolerance'))	
		end
		infobox:node(p.add_entry('V<sub>core</sub>', vcore))
	end
	if has_arg('v core min') then
		p.set_val('core voltage (min)', arg('v core min'))
		p.set_val('core voltage (max)', arg('v core max'))
		infobox:node(p.add_entry('V<sub>core</sub>', mw.html.create('td'):wikitext(arg('v core min') .. '-' .. arg('v core max'))))
	end

	-- io
	if has_arg('v io') then
		p.set_val('io voltage', arg('v io'))
		local vcore =  mw.html.create('td'):wikitext(arg('v io'))
		if has_arg('v io tolerance') then
			p.set_val('io voltage tolerance', arg('v io tolerance'))
			vcore:wikitext(' ± ' .. arg('v io tolerance'))
		end
		for i = 2, 10 do
	  		if not has_arg('v io ' .. i) then break end
			p.set_val('io voltage', arg('v io ' .. i))
	  		vcore:wikitext(', ' .. arg('v io ' .. i))
		end
		infobox:node(p.add_entry('V<sub>I/O</sub>', vcore))
	end
	
	-- sdp
	if has_arg('sdp') then
		p.set_val('sdp', arg('sdp'))
	  infobox:node(p.add_entry('<abbr title="Scenario Design Power">SDP</abbr>', mw.html.create('td'):wikitext(arg('sdp'))))
	end
	
	-- tdp
	if has_arg('tdp') then
		p.set_val('tdp', arg('tdp'))
		local tdp =  mw.html.create('td'):wikitext(arg('tdp'))
		for i = 2, 10 do
	  		if not has_arg('tdp ' .. i) then break end
			p.set_val('tdp', arg('tdp ' .. i))
	  		tdp:wikitext(', ' .. arg('tdp ' .. i))
		end
	  	infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr>', tdp))
	end
	
	-- tdp typical
	if has_arg('tdp typical') then
		p.set_val('tdp (typical)', arg('tdp typical'))
		infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr> (Typical)', mw.html.create('td'):wikitext(arg('tdp typical'))))
	end
	
	-- ctdp down
	if has_arg('ctdp down') then
		p.set_val('tdp down', arg('ctdp down'))
	  	infobox:node(p.add_entry('cTDP down', mw.html.create('td'):wikitext(arg('ctdp down'))))
	end
	
	-- ctdp down
	if has_arg('ctdp down frequency') then
		p.set_val('tdp down frequency', arg('ctdp down frequency'))
		infobox:node(p.add_entry('cTDP down frequency', mw.html.create('td'):wikitext(arg('ctdp down frequency'))))
	end
	
	-- ctdp up
	if has_arg('ctdp up') then
		p.set_val('tdp up', arg('ctdp up'))
	  	infobox:node(p.add_entry('cTDP up', mw.html.create('td'):wikitext(arg('ctdp up'))))
	end
	
	-- ctdp up
	if has_arg('ctdp up frequency') then
		p.set_val('tdp up frequency', arg('ctdp up frequency'))
	  	infobox:node(p.add_entry('cTDP up frequency', mw.html.create('td'):wikitext(arg('ctdp up frequency'))))
	end
	
	-- temp min
	if has_arg('temp min') or has_arg('temp max') then
		if has_arg('temp min') then p.set_val('min operating temperature', arg('temp min')) end
		if has_arg('temp max') then p.set_val('max operating temperature', arg('temp max')) end
	  	infobox:node(p.add_entry('OP Temperature', mw.html.create('td'):wikitext(arg('temp min') .. '&nbsp;–&nbsp;' .. arg('temp max'))))
	end
	
	-- tjunc min
	if has_arg('tjunc min') or has_arg('tjunc max') then
		if has_arg('tjunc min') then p.set_val('min junction temperature', arg('tjunc min')) end
		if has_arg('tjunc max') then p.set_val('max junction temperature', arg('tjunc max')) end
	  	infobox:node(p.add_entry('T<sub>junction</sub>', mw.html.create('td'):wikitext(arg('tjunc min') .. '&nbsp;–&nbsp;' .. arg('tjunc max'))))
	end
	
	-- tcase min
	if has_arg('tcase min') or has_arg('tcase max') then
		if has_arg('tcase min') then p.set_val('min case temperature', arg('tcase min')) end
		if has_arg('tcase max') then p.set_val('max case temperature', arg('tcase max')) end
	  	infobox:node(p.add_entry('T<sub>case</sub>', mw.html.create('td'):wikitext(arg('tcase min') .. '&nbsp;–&nbsp;' .. arg('tcase max'))))
	end
	
	-- tstorage min
	if has_arg('tstorage min') or has_arg('tstorage max') then
		if has_arg('tstorage min') then p.set_val('min storage temperature', arg('tstorage min')) end
		if has_arg('tstorage max') then p.set_val('max storage temperature', arg('tstorage max')) end
	  	infobox:node(p.add_entry('T<sub>storage</sub>', mw.html.create('td'):wikitext(arg('tstorage min') .. '&nbsp;–&nbsp;' .. arg('tstorage max'))))
	end
	
	-- tambient min
	if has_arg('tambient min') or has_arg('tambient max') then
		if arg('tambient min') then p.set_val('min ambient temperature', arg('tambient min')) end
		if arg('tambient max') then p.set_val('max ambient temperature', arg('tambient max')) end
		infobox:node(p.add_entry('T<sub>ambient</sub>', mw.html.create('td'):wikitext(arg('tambient min') .. '&nbsp;–&nbsp;' .. arg('tambient max'))))
	end
	
	-- dts min/max
	if has_arg('dts min') or has_arg('dts max') then
		if has_arg('dts min') then p.set_val('min dts temperature', arg('dts min')) end
		if has_arg('dts max') then p.set_val('max dts temperature', arg('dts max')) end
		infobox:node(p.add_entry('T<sub>DTS</sub>', mw.html.create('td'):wikitext(arg('dts min') .. '&nbsp;–&nbsp;' .. arg('dts max'))))
	end
	
	

    -- ####################################################################
    -- Packaging
    if has_arg('package module 1') or has_arg('package name 1') or has_arg('back image') then
        p.add_separator(infobox, 'Packaging')
    end
    
    -- Packaging
    if has_arg('package name 1') then
    	local pdata = require('Module:packaging data')
		for i = 1, 10 do
		    if has_arg('package name ' .. i) then
		        local package_name = arg('package name ' .. i)
		        local package_location = {}
		        for field in string.gmatch(package_name, "([^,]+),?") do
		            table.insert(package_location, field)
		        end
		        
		        -- company, package
		        local package_info = pdata['packages'][package_location[1]][package_location[2]]
		        
		        -- name
		        if package_info.p_name ~= nil then
			        local package_name
			        for key,name in ipairs(package_info.p_name) do
			            package_name = (package_name == nil) and name or package_name .. ', ' .. name
						p.set_val('package', name)
			        end
			        
			        if package_info.p_type ~= nil then
			        	package_name = package_name .. ' (' .. package_info.p_type .. ')'
		        	end
			        
			        infobox:node(p.add_entry('Package', mw.html.create('td'):wikitext(package_name)))
			        
			        if package_info.p_type ~= nil then
			        	package_name = package_name .. '(' .. package_info.p_type .. ')'
	        		end
        		end
        	
        		-- dimensions
        		if package_info.p_size ~= nil then
        			local package_dimension = package_info.p_size[1] .. ' × ' .. package_info.p_size[2]
        			if package_info.p_size[3] ~= nil then
        				package_dimension = package_dimension .. ' × ' .. package_info.p_size[3]
    				end
			        infobox:node(p.add_entry('Dimension', mw.html.create('td'):wikitext(package_dimension)))
    			end
        	
        		-- pitch
        		if package_info.p_pitch ~= nil then
			        local package_pitch
			        for key,pitch in ipairs(package_info.p_pitch) do
			            package_pitch = (package_pitch == nil) and pitch or package_pitch .. ' × ' .. pitch
			        end
			        infobox:node(p.add_entry('Pitch', mw.html.create('td'):wikitext(package_pitch)))
    			end
        	
        		-- contacts
        		if package_info.p_contacts ~= nil then
			        infobox:node(p.add_entry('Contacts', mw.html.create('td'):wikitext(package_info.p_contacts)))
    			end
        	
        		-- socket
        		if package_info.p_socket ~= nil then
			        local package_socket
			        for key,socket in ipairs(package_info.p_socket) do
			            package_socket = (package_socket == nil) and socket or package_socket .. ', ' .. socket
						p.set_val('socket', socket)
			        end
			        infobox:node(p.add_entry('Socket', mw.html.create('td'):wikitext(package_socket)))
    			end
		        
		    end
		end
	end
    
    -- Packaging
    if has_arg('package module 1') then
		for i = 1, 10 do
		    if has_arg('package module ' .. i) then
				infobox
					:tag('tr'):tag('td'):attr('colspan', '2'):attr('style', 'padding: 5px;')
					:wikitext(frame:preprocess(arg('package module ' .. i)))
			end
		end
	end

    -- back_image
	if has_arg('back image') then
		local back_image = p.add_file_prefix(arg('back image'))
		local back_image_size = has_arg('back image size') and arg('back image size') or "200px" 
		infobox
		:tag('tr')
		  :tag('td')
		    :attr('style', 'text-align: center;')
		    :attr('colspan', '2')
		    -- make sure it's the ogimage
		    :wikitext('[[' .. back_image .. '|link=|' .. back_image_size .. ']]')
		
		p.set_val('back image', back_image)
	end


    -- ####################################################################
    -- ####################################################################
    -- Successon
	if has_arg('successor') or has_arg('predecessor') then
        p.add_separator(infobox, 'Succession')
		
		local s = infobox:tag('tr')
		local td = s:tag('td'):attr('colspan', '2')
		local d1 = td:tag('div'):attr('style', 'display: inline-flex;')
		local d2 = td:tag('div'):attr('style', 'display: inline-flex; float: right;')
		if has_arg('predecessor') then
			
		    local list
		    if has_arg('predecessor link') then
				list = '[[' .. arg('predecessor link') .. '|' .. arg('predecessor') .. ']]'
			else
				list = '[[' .. arg('predecessor') .. ']]'
			end
		    for i = 2, 10 do
		    	if not has_arg('predecessor ' .. i) then break end
		    	if has_arg('predecessor ' .. i .. ' link') then
		    		list = list .. '<br>[[' .. arg('predecessor ' .. i .. ' link') .. '|' .. arg('predecessor ' .. i) .. ']]'
	    		else
		    		list = list .. '<br>[[' .. arg('predecessor ' .. i) .. ']]'
    			end
			end
			
			d1:tag('div')
				:attr('style', 'float: left; padding-right: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-left"></i>')
			d1:tag('div')
				:attr('style', 'float: left;')
				:wikitext(list)
		end
		if has_arg('successor') then
			local list
		    if has_arg('successor link') then
				list = '[[' .. arg('successor link') .. '|' .. arg('successor') .. ']]'
			else
				list = '[[' .. arg('successor') .. ']]'
			end
		    for i = 2, 10 do
		    	if not has_arg('successor ' .. i) then break end
		    	if has_arg('successor ' .. i .. ' link') then
		    		list = list .. '<br>[[' .. arg('successor ' .. i .. ' link') .. '|' ..
		    			arg('successor ' .. i) .. ']]'
	    		else
		    		list = list .. '<br>[[' .. arg('successor ' .. i) .. ']]'
    			end
			end
			
			d2:tag('div')
				:attr('style', 'float: left;')
				:wikitext(list)
			d2:tag('div')
				:attr('style', 'float: right; padding-left: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-right"></i>')
		end
	end
    -- Contemporary
	if has_arg('contemporary') then
        p.add_separator(infobox, 'Contemporary')
		
		local s = infobox:tag('tr')
		local td = s:tag('td'):attr('colspan', '2')
		
		td:attr('style', 'text-align: center;')

	    local list
	    if has_arg('contemporary link') then
			list = '[[' .. arg('contemporary link') .. '|' .. arg('contemporary') .. ']]'
		else
			list = '[[' .. arg('contemporary') .. ']]'
		end
	    for i = 2, 10 do
	    	if not has_arg('contemporary ' .. i) then break end
	    	if has_arg('contemporary ' .. i .. ' link') then
	    		list = list .. '<br>[[' .. arg('contemporary ' .. i .. ' link') .. '|' .. arg('contemporary ' .. i) .. ']]'
    		else
	    		list = list .. '<br>[[' .. arg('contemporary ' .. i) .. ']]'
			end
		end
		
		td:wikitext(list)
	end





	if has_arg('packaging') or has_arg('package 0') then
		infobox:wikitext('[[Category:Articles with invalid parameter in template]]')	
	end
	
	p.set_val('full page name', frame:preprocess('{{FULLPAGENAME}}'))
    
    if has_arg('future') and
    	(string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
		p.set_val('ldate', '3000')
    	infobox:wikitext('[[Category:future ' .. chip_type .. ' models]]')
	elseif has_arg('first launched') then
		p.set_val('ldate', arg('first launched'))
	elseif has_arg('first announced') then
		p.set_val('ldate', arg('first announced'))
	else --alright launched but no date?
		p.set_val('ldate', '1900')
    end
	
    return infobox
end

return p